import { createSlice } from "@reduxjs/toolkit";


function currenttime() {
    const date = new Date();
    // 获取小时数（0-23）  
    const hours = date.getHours();
    if (hours >= 6 && hours < 18) {
        return true;
    } else {
        return false
    }

}

const Appstore = createSlice({
    name: "Appstore",
    initialState: {
        count: 1000,
        theme: currenttime()
    },
    reducers: {
        testcount: (state, { payload }) => {
            state.count = payload
        },
        setTheme: state => {
            state.theme = !state.theme
        }
    },

})


export const { testcount, setTheme } = Appstore.actions



export default Appstore.reducer